﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Subtle.Domain.Models;
using Subtle.Domain.Services.Interfaces;

namespace Subtle.Controllers
{
	public class MediaController : BaseController
	{
		private IMediaService MediaService;

		/// <summary>
		/// Initializes a Home Controller
		/// </summary>
		/// <param name="MediaService"></param>
		public MediaController(IMediaService MediaService)
		{
			this.MediaService = MediaService;
		}

		/// <summary>
		/// Get Media
		/// </summary>
		/// <param name="MediaName"></param>
		/// <returns></returns>
		[OutputCache(VaryByParam = "id", Duration = 86400)] //ToDo : Make configurable
		public ActionResult Show(int id)
		{
			Media foundMedia = MediaService.Get(id);
			return File(foundMedia.Contents, foundMedia.Type);
		}
	}
}
